package com.gopher.gopherbeasts;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL10;

public class GameEngine extends MyGame {

	public static final int TICKS_PER_SECOND = 50;
	public static final int SKIP_TIME = 1000 / TICKS_PER_SECOND;

	public float time = 0f;

	public InputHandler input = new InputHandler();


	public void create() {
		Art.load();
		Sound.load();
		Gdx.input.setInputProcessor(input);
		setScreen(new GameScreen(this));
	}

	public void resize(int width, int height) {

	}

	public void render() {

		// clear screen with blackish color
		Gdx.gl.glClearColor(.1f, .1f, .1f, 1f);
		Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

		time += Gdx.graphics.getDeltaTime();

		while (time > 1.0f / TICKS_PER_SECOND) {
			input.update();
			getScreen().update();
			time -= 1.0f / TICKS_PER_SECOND;
		}

		float interpolation = time / (float) (SKIP_TIME);

		getScreen().render(interpolation);

	}
}
